-- airship_console
-- created by chendh
-- 飞艇控制台

return {
    doAction = function(action)
        local grid = DungeonM.getGridByPos(action.pos);
        if type(grid) ~= "table" or grid.type ~= GRID_TYPE_AIRSHIP_CONSOLE then
            return false;
        end

        -- 所有格子
        local grids = DungeonM.getCurrentDungeon();
        for _, g in pairs(grids) do
            if not g:isOpened() then
                g:open(nil, true);
            end
        end

        -- 飞艇控制台格子变为无效状态
        grid:changeState(GRID_STATE_DISABLE);

        -- 通知建筑事件完成
        EventMgr.fire(event.BUILDING_EVENT_DONE, {["pos"] = action.pos,});

        return true;
    end,
};
